package org.theqcp.wow.sim.gui.tabs;

import java.awt.BorderLayout;

import javax.swing.BoxLayout;
import javax.swing.GroupLayout;
import javax.swing.JPanel;
import javax.swing.GroupLayout.SequentialGroup;
import javax.swing.border.TitledBorder;

import org.theqcp.wow.sim.gui.DataPoint;
import org.theqcp.wow.sim.gui.EnhSimGUIFrame;

public class DamageRotation extends DataPanel {

    private static final long serialVersionUID = -378890568607579088L;

    protected final String[] two = new String[] { "0", "1", "2" };
    protected final String[] six = new String[] { "0", "1", "2", "3", "4", "5", "6" };
    protected final String[] nine = new String[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };

    public DamageRotation(EnhSimGUIFrame esgFrame) {
	fieldNames.put("MH auto attack", DataPoint.mh_auto_attack);
	fieldNames.put("OH auto attack", DataPoint.oh_auto_attack);
	fieldNames.put("Wait SS with WF cd", DataPoint.wait_ss_with_wf_cd);
	fieldNames.put("Cast LL only if WF on cd", DataPoint.cast_ll_only_if_wf_on_cd);
	fieldNames.put("Bloodlust casters", DataPoint.bloodlust_casters);
	fieldNames.put("Sync Bloodlust with trinkets", DataPoint.sync_bloodlust_with_trinkets);
	fieldNames.put("Cast LvB only if ED left", DataPoint.cast_lvb_only_if_ed_left);
	fieldNames.put("Cast LvB only if FS dots left", DataPoint.cast_lvb_only_if_fsdots_left);
	fieldNames.put("Cast LvB only if FS active", DataPoint.cast_lvb_only_if_fs_active);
	fieldNames.put("Cast FS only if dots left", DataPoint.cast_fs_only_if_dots_left);
	fieldNames.put("Cast LS only if charges left", DataPoint.cast_ls_only_if_charges_left);
	fieldNames.put("Cast SR only if mana left", DataPoint.cast_sr_only_if_mana_left);
	fieldNames.put("Use mana potion if mana left", DataPoint.use_mana_potion_if_mana_left);

	setupFrame(esgFrame);
    }

    private void setupFrame( EnhSimGUIFrame esgFrame ) {
	// setLayout(new BorderLayout());
	// setLayout(new FlowLayout());
	JPanel p = new JPanel(new BorderLayout());
	add(p, BorderLayout.CENTER);

	GroupLayout gl = new GroupLayout(p);
	gl.setAutoCreateContainerGaps(true);
	gl.setAutoCreateGaps(true);

	p.setLayout(gl);

	SequentialGroup hGroup = gl.createSequentialGroup();
	SequentialGroup vGroup = gl.createSequentialGroup();

	JPanel misc = new JPanel();
	misc.setLayout(new BoxLayout(misc, BoxLayout.Y_AXIS));
	misc.setBorder(new TitledBorder("Rotation and Misc"));
	// add(misc);

	RotationPriority rotation = new RotationPriority(esgFrame);
	esgFrame.addDataPoint(DataPoint.rotation_priority, rotation);
	// add(rotation);

	hGroup.addGroup(gl.createParallelGroup().addComponent(misc));
	hGroup.addGroup(gl.createParallelGroup().addComponent(rotation));
	vGroup.addGroup(gl.createParallelGroup().addComponent(misc).addComponent(rotation));

	gl.setHorizontalGroup(hGroup);
	gl.setVerticalGroup(vGroup);

	addCheckBox(esgFrame, misc, "MH auto attack");
	addCheckBox(esgFrame, misc, "OH auto attack");
	addTextField(esgFrame, misc, "Wait SS with WF cd");
	addCheckBox(esgFrame, misc, "Cast LL only if WF on cd");
	misc.add(makeComboBox(esgFrame, "Bloodlust casters", two));
	addCheckBox(esgFrame, misc, "Sync Bloodlust with trinkets");
	addTextField(esgFrame, misc, "Cast LvB only if ED left");
	misc.add(makeComboBox(esgFrame, "Cast LvB only if FS dots left", six));
	addCheckBox(esgFrame, misc, "Cast LvB only if FS active");
	misc.add(makeComboBox(esgFrame, "Cast FS only if dots left", six));
	misc.add(makeComboBox(esgFrame, "Cast LS only if charges left", nine));
	addTextField(esgFrame, misc, "Cast SR only if mana left");
	addTextField(esgFrame, misc, "Use mana potion if mana left");
    }
}
